package com.whfc.cncit.helmet.processor;

import com.whfc.cncit.constant.CncitConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/8/29 15:13
 */
@Component
public class HelmetUpMsgProcessorFactory {

    private Logger logger = LoggerFactory.getLogger(HelmetUpMsgProcessorFactory.class);

    @Autowired
    private HelmetUpMsgProcessorS processorS;

    @Autowired
    private HelmetUpMsgProcessorPSA processorPSA;

    @Autowired
    private HelmetUpMsgProcessorR processorR;

    /**
     * 获取消息处理器
     *
     * @param cmd
     * @return
     */
    public CncitUpMsgProcessor getMsgProcessor(String cmd) {
        CncitUpMsgProcessor processor = null;
        switch (cmd) {
            case CncitConst.UP_CMD_S:
                processor = processorS;
                break;
            case CncitConst.UP_CMD_H:
                processor = processorS;
                break;
            case CncitConst.UP_CMD_PSA:
                processor = processorPSA;
                break;
            case CncitConst.UP_CMD_R:
                processor = processorR;
                break;
            default:
                logger.info("无法解析的指令,cmd:{}", cmd);
                break;
        }
        return processor;
    }
}
